#ifndef MSDOS
#include <stdio.h>
#include "term.h"
/*
 * gettermtype - finds terminal type and reads termcap entry for it.
 */
gettermtype()
{
	char	tptr[1024], *termtyp, *tbufptr;

	termtyp = (char *)getenv("TERM");

	switch (tgetent(tptr, termtyp)) {
	case -1:
		fprintf(stderr, "\nBASIC: can't read termcap\n");
		exit(1);
	case 0:
		fprintf(stderr,"\nBASIC: invalid terminal type (%s)\n",termtyp);
		exit(1);
	}
	tbufptr = tbuf;
	AE = tgetstr("eA", &tbufptr);
	AL = tgetstr("al", &tbufptr);
	AS = tgetstr("as", &tbufptr);
	BC = tgetstr("bc", &tbufptr);
	BL = tgetstr("bl", &tbufptr);
	if (!BL)
		BL = "\007";
	BS = tgetflag("bs", &tbufptr);
	if (!BC && BS)
		BC = "\b";
	CD = tgetstr("cd", &tbufptr);
	CE = tgetstr("ce", &tbufptr);
	CL = tgetstr("cl", &tbufptr);
	CM = tgetstr("cm", &tbufptr);
	CO = tgetnum("co");
	CR = tgetstr("cr", &tbufptr);
	if (!CR)
		CR = "\r";
	CS = tgetstr("cs", &tbufptr);
	DL = tgetstr("dl", &tbufptr);
	DO = tgetstr("do", &tbufptr);
	if (!DO)
		DO = "\n";
	ED = tgetstr("sf", &tbufptr);
	EM = tgetstr("sr", &tbufptr);
	KE = tgetstr("ke", &tbufptr);
	KS = tgetstr("ks", &tbufptr);
	LI = tgetnum("li");
	MAL = tgetstr("AL", &tbufptr);
	MB = tgetstr("mb", &tbufptr);
	MDL = tgetstr("DL", &tbufptr);
	ME = tgetstr("me", &tbufptr);
	MR = tgetstr("mr", &tbufptr);
	ND = tgetstr("nd", &tbufptr);
	NL = tgetstr("nl", &tbufptr);
	if (!NL)
		NL = "\n";
	RC = tgetstr("rc", &tbufptr);
	SC = tgetstr("sc", &tbufptr);
	SE = tgetstr("se", &tbufptr);
	SO = tgetstr("so", &tbufptr);
	SR = tgetstr("sr", &tbufptr);
	TI = tgetstr("ti", &tbufptr);
	if (!TI) {
		TI = tgetstr("vs", &tbufptr);
		TE = tgetstr("ve", &tbufptr);
	}
	TE = tgetstr("te", &tbufptr);
	UE = tgetstr("ue", &tbufptr);
	UP = tgetstr("up", &tbufptr);
	US = tgetstr("us", &tbufptr);

	/* validate termcap info */
	if (CO < 80 || LI < 24) {
		fprintf(stderr, "\nBASIC: requires 24 by 80 line screen.\n");
		exit(1);
	}
	if (!CM) {
		fprintf(stderr,"BASIC: cursor motion ability required (cm).\n");
		exit(1);
	}
	if (!CL) {
		fprintf(stderr,"BASIC: requires clear screen ability (cl).\n");
		exit(1);
	}
	if (!UP) {
		fprintf(stderr, "BASIC: requires cursor up capability (up).\n");
		exit(1);
	}
}


/*
 * outchar - used by tputs to write characters
 */
void
outchar(c)
int	c;
{
	putchar(c);
	return;
}


#endif
